﻿<phone:PhoneApplicationPage 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:my="clr-namespace:ALiteTeam.PackageTracer.View" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"     
    x:Class="ALiteTeam.PackageTracer.View.MainPage"
    mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    DataContext="{Binding MainPageViewModel, Source={StaticResource ViewModelLocator}}"
    shell:SystemTray.IsVisible="True" d:DesignHeight="768" d:DesignWidth="480" >
   
    
    <!--定义物理键BackKeyPress事件-->
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="BackKeyPress">
            <GalaSoft_MvvmLight_Command:EventToCommand
                Command="{Binding BackKeyPressCommand}"
                PassEventArgsToCommand="True"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity="0.5">
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="{Binding BackgroundImage, Source={StaticResource ViewModelLocator}}"/>
        </Grid.Background>
        <!--ContentPanel - place additional content here-->
        <controls:Pivot HorizontalAlignment="Left" x:Name="pivot" Title="风讯快递查询" VerticalAlignment="Top" SelectedIndex="{Binding PivotSelectedIndex}" LoadingPivotItem="pivot_LoadingPivotItem">
            <controls:PivotItem Header="快递选择" x:Name="pivotItemChooseDelivery" Width="Auto" IsEnabled="True">
                <StackPanel Orientation="Vertical">
                    <TextBlock Height="30" HorizontalAlignment="Left" Margin="0" x:Name="textBlock" Text="请选择快递：" VerticalAlignment="Top" />
                    <ItemsControl  Margin="0, -10" x:Name="itemsControl" ItemsSource="{Binding PriorityDeliveries}" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <toolkit:WrapPanel>
                                    <!--设定ItemsControl控件之间的间距-->
                                    <toolkit:WrapPanel.Resources>
                                        <Style TargetType="RadioButton">
                                            <Setter Property="Margin" Value="0, -5, 0, 0" />
                                            <Setter Property="Padding" Value="0" />
                                        </Style>
                                    </toolkit:WrapPanel.Resources>
                                </toolkit:WrapPanel>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <RadioButton Content="{Binding Name}" GroupName="Favors" FontSize="32" Height="80"
                                             Command="{Binding NavigationToInputCommand}"
                                             CommandParameter="{Binding DeliveryID}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                    <RadioButton Content="选择其他..." x:Name="rdBtnOthers" GroupName="Favors" FontSize="32" Height="80" Command="{Binding NavigationToSelectorCommand}" />
                </StackPanel>
            </controls:PivotItem>
            <controls:PivotItem Header="我的运单" x:Name="pivotItemMyOrders" FontSize="20" Width="Auto">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Loaded">
                        <GalaSoft_MvvmLight_Command:EventToCommand
                            x:Name="LoadDeliveryOrders"
                            Command="{Binding LoadDeliveryOrdersCommand}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" >                    
                    <Grid Width="470" Height="535">
                        <toolkit:MultiselectList x:Name="multiList" HorizontalAlignment="Left" VerticalAlignment="Top" Height="Auto" Width="470" ItemsSource="{Binding DeliveryOrders}">
                            <toolkit:MultiselectList.ItemTemplate>
                                <DataTemplate>
                                    <my:DeliveryOrderControl/>
                                </DataTemplate>
                            </toolkit:MultiselectList.ItemTemplate>
                        </toolkit:MultiselectList>
                    </Grid>
                </ScrollViewer>
            </controls:PivotItem>            
        </controls:Pivot>        
    </Grid>
</phone:PhoneApplicationPage>